{% extends "blogs/admin/base.html" %}
{% load i18n %}

{% block title %}Blogtool{% endblock %}

{% block content_title %}{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block content %}

    {% if blogs %}
        <p>{%if user.is_superuser %}Here is a list of all the blogs.
        {% else %}You belong to the following blogs.{% endif %}</p>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Description</th>
                    <th>Users</th>
                    <th>Latest Posts</th>
                </tr>
            </thead>
            <tbody>
        {% for blog in blogs %}
                <tr>
                    <td><a href="{% url blogs.admin.dashboard blog.slug %}">{{ blog.name }}</a></td>
                    <td>{{ blog.description|truncatewords_html:100|striptags }}</td>
                    <td>{{ blog.users.all|join:", " }}</td>
                    <td>
                        {% for post in blog.get_posts %}
                            <a href="{% url blogs.admin.edit_post blog.slug,post.id %}">{{ post }}</a>{% if not forloop.last %},{% endif %}
                        {% endfor %}
                    </td>
                </tr>
        {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>Sorry, you have no blogs available.</p>
    {% endif %}

{% endblock %}